import time

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support.select import Select


driver = webdriver.Chrome()
driver.maximize_window()
driver.get("https://ebank.xacbank.com/XAEIBankDemo/page/login/login.html?t=1763464483511")

#显式等待页面加载
locator1=("id","login")
e = WebDriverWait(driver,20,0.5).until(expected_conditions.presence_of_element_located(locator=locator1))
#select选择企业多人模式
se1 = driver.find_element("id","openModel")
select1=Select(se1)
texts1= select1.options
list1=[]
for text in texts1:
    list1.append(text.text)
select1.select_by_visible_text(list1[2])

time.sleep(2)
#select2选择提交员
se2 = driver.find_element("id","operType")
select2=Select(se2)
select2=Select(se2)
texts2= select2.options
list2=[]
for text in texts2:
    list1.append(text.text)
select1.select_by_visible_text(list1[1])
time.sleep(2)

driver.find_element("id","account").send_keys("123456")
driver.find_element("id","login").click()

time.sleep(4)
#动态等待关弹窗
# locator2=("id","fw-gen-10009-closable")
# e=WebDriverWait(driver,20,0.5).until(expected_conditions.presence_of_element_located(locator=locator2))

driver.find_element("id","fw-gen-10009-closable").click()
#点击转账汇款
time.sleep(2)
driver.find_element("class name","title_icon.icon-menu2").click()
time.sleep(2)
driver.find_element("link text","行内批量转账").click()
time.sleep(2)

#切到最外层frame
driver.switch_to.default_content()
# 进入角色选择iframe弹窗
i=driver.find_element("id","fw-gen-10007-body")
#切换iframe
driver.switch_to.frame(i)

#选择付款账号

lis=driver.find_element("id","payAccount")
select_Pay=Select(lis)
Pays=select_Pay.options
Pays_list=[]
for Pay in Pays:
    Pays_list.append(Pay.text)
select_Pay.select_by_visible_text(Pays_list[1])


driver.switch_to.default_content()


#动态等待关弹窗
i=driver.find_element("id","fw-gen-10007-body")
#切换iframe
driver.switch_to.frame(i)
locator3=("id","icon_find1")
e = WebDriverWait(driver,20,0.5).until(expected_conditions.presence_of_element_located(locator=locator3))
driver.find_element("id","icon_find1").click()


#切到最外层frame
driver.switch_to.default_content()
# 进入角色选择iframe弹窗
time.sleep(2)
i=driver.find_element("id","fw-gen-10011-iframe")
#切换iframe
time.sleep(2)
driver.switch_to.frame(i)
#选择俩人
time.sleep(2)
driver.find_element('xpath','/html/body/div/div[3]/div/table/tbody/tr[2]/td[2]').click()
time.sleep(1)
driver.find_element(By.XPATH,'/html/body/div/div[3]/div/table/tbody/tr[3]/td[2]').click()
driver.switch_to.default_content()
time.sleep(1)


driver.find_element("class name","btn.btn-primary").click()
time.sleep(1)


#切到最外层frame
driver.switch_to.default_content()
# 进入角色选择iframe弹窗
i=driver.find_element("id","fw-gen-10007-body")
#切换iframe
driver.switch_to.frame(i)

driver.find_element("xpath","/html/body/div/table[2]/tbody/tr[1]/td[4]/input").send_keys("1000")
time.sleep(1)
driver.find_element("xpath","/html/body/div/table[2]/tbody/tr[2]/td[4]/input").send_keys("9000")
time.sleep(2)

driver.switch_to.default_content()
# 进入角色选择iframe弹窗
i=driver.find_element("id","fw-gen-10007-body")
#切换iframe
driver.switch_to.frame(i)

driver.find_element("id","next_btn").click()
time.sleep(2)
i=driver.find_element("id","batchTempName").send_keys('allllll')
time.sleep(2)
driver.find_element("id","submit_btn").click()
time.sleep(2)
text=driver.find_element('xpath','/html/body/div/div[4]/form/div/div/div[2]/div[1]/span[2]')
time.sleep(2)
print(text.text)
driver.close()